package com.gpj.mini.tools.fr;

import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @className Main
 * @description
 *   TODO
 * @author GPJ
 * @date 2021/6/17 16:55
 * @version 1.0
 **/
@Slf4j
public class Main {
	public static void main(String[] args) {
		String path = "E:/workspace/GitRepository/spring-docs";
		String source = "https://github.com/DocsHome";
		String target = "https://gitee.com/guangpj";
		Main.run(path, source, target);
	}

	public static void run(String path, String source, String target){
		DirScan dirScan = new DirScan(path, ".md");
		List<String> paths = dirScan.scan();
		if(paths.isEmpty()) {
			log.warn("路劲[{}]下未找到文件", path);
			return;
		}

		for (String filePath : paths) {
			boolean result = FindAndReplace.findReplace(filePath, source, target);
			if(result){
				log.info("文件替换成功,文件路径:{}", filePath);
			}else{
				log.warn("文件替换失败,文件路径:{}", filePath);
			}
		}
	}
}
